package com.PVZ.event;

import com.PVZ.model.Entity;
import com.PVZ.model.bullet.Sun;
import com.PVZ.model.emuns.EventType;
import com.PVZ.model.emuns.MoveType;
import com.PVZ.model.interfaces.EventListener;
import com.PVZ.model.interfaces.Gettable;

/**
 * Created by @Author: kabuda on @Date: 2021/5/30 18:18
 */
public class ClickGettableListener implements EventListener {
    @Override
    public void eventHandler(Event event) {
        if(event.getEventType()== EventType.GET){
            //事件类型为拾取
            Entity entity = ((ClickGettableEvent) event).gettableEntity;

            if(entity instanceof Gettable){
                //判断是否可拾取
                if (entity instanceof Sun) {
                    //拾取对象为阳光
                    Sun sun = (Sun) entity;
                    //设置移动方式为往左上方移
                    sun.setMoveType(MoveType.LeftUp);

                    //金钱系统....
                }

            }
        }
    }
}
